package com.zygh.interactiveplatform.module.controller;


import com.alibaba.fastjson.JSONObject;
import com.zygh.interactiveplatform.common.anno.PcLog;
import com.zygh.interactiveplatform.common.constant.SwaggerTagConst;
import com.zygh.interactiveplatform.common.domain.ResponseDTO;
import com.zygh.interactiveplatform.module.entity.DirectionCode;
import com.zygh.interactiveplatform.module.service.DirectionCodeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lee
 * @since 2021-01-29
 */
@RestController
@RequestMapping("/direction-code")
@Api(tags = {SwaggerTagConst.Admin.MANAGER_DIRECTIONCODE})
public class DirectionCodeController {
    @Resource
    private DirectionCodeService directionCodeService;

    @ApiOperation(value = "新增方向编码", notes = "新增方向编码")
    @PostMapping("addDirectionCodee")
    @PcLog(logType = "2", module = SwaggerTagConst.Admin.MANAGER_DIRECTIONCODE, content = "新增方向编码")
    public ResponseDTO addDirectionCodee(@RequestBody @Valid DirectionCode directionCode) {
        return directionCodeService.addDirectionCode(directionCode);
    }
    @ApiOperation(value = "修改方向编码", notes = "修改方向编码")
    @PostMapping("updateDirectionCode")
    @PcLog(logType = "3", module = SwaggerTagConst.Admin.MANAGER_DIRECTIONCODE, content = "修改方向编码")
    public ResponseDTO updateDirectionCode(@RequestBody @Valid DirectionCode directionCode) {
        return directionCodeService.updateDirectionCode(directionCode);
    }
    @ApiOperation(value = "删除方向编码", notes = "删除方向编码")
    @PostMapping("deleteDirectionCode")
    @PcLog(logType = "4", module = SwaggerTagConst.Admin.MANAGER_DIRECTIONCODE, content = "删除方向编码")
    public ResponseDTO deleteDirectionCode(@RequestBody String id) {
        String s = JSONObject.parseObject(id).get("id").toString();
        Integer new_id = Integer.parseInt(s);
        return directionCodeService.deleteDirectionCode(new_id);
    }
    @ApiOperation(value = "查询所有方向编码", notes = "查询所有方向编码")
    @GetMapping("findDirectionCodeAll")
    @PcLog(logType = "1", module = SwaggerTagConst.Admin.MANAGER_DIRECTIONCODE, content = "查询所有方向编码")
    public ResponseDTO findDirectionCodeAll(Integer current, Integer size) {
        return directionCodeService.findDirectionCodeAll(current,size);
    }
}
